<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String msg=(String)request.getAttribute("msg");

%>

<!DOCTYPE HTML >
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'login.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    This is my JSP page. <br>
    <form action="login1.html" method="post">
   用户名：  <input type="text" name="username"><br/>
    密 &nbsp;码：      <input type="password" name="password">
         <input type="submit" value="提交"/><br/>
  验证码 :    <input type="text" name="valueCode" id="valueCode" onkeyup="ajxValueCode()"><br/>
         <img src="identity.html" id="image" onclick="ChangeCode()"/>
    </form>
    
  </body>
  <script><!--
  var msg="<%=msg%>";
  if(msg!="null"){
  alert(msg);
  }
  function ChangeCode(){
  image=document.getElementById("image");
  image.src="identity.html?time="+new Date();    //参数变化则可以刷新页面
  }
  function  ajxValueCode(){
  	var valueCode=document.getElementById("valueCode").value; //获得属性值
				if(valueCode.length>0&&valueCode.length==4){  
					var xmlhttp=null;
					if (window.XMLHttpRequest){
						xmlhttp=new XMLHttpRequest();
					}else{
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.open("GET","<%=basePath%>value.html?valueCode="+valueCode,false); 
					xmlhttp.send();
					var data=xmlhttp.responseText; 
					//alert(data);
					var json=JSON.parse(data);  //把data解析为json
				//	alert(json.flag);
					if(json.flag==false){
						alert(json.msg);
					/*  document.getElementById("validateCode").value="";
						document.getElementById("validateCode").focus();*/
					}
				}else{
				}
  	
  
  }
  --></script>
  
</html>
